#include<windows.h>
#include <stdlib.h>
#include "PaintBrush.h"


ptrFigure CreateFigure(POINT prmPoint1, POINT prmPoint2, int prmFigure,COLORREF prmColor)
{
	ptrFigure tmpFigure = (ptrFigure) malloc(sizeof(Figure)); 
			tmpFigure->sPoint1=prmPoint1;
			tmpFigure->sPoint2=prmPoint2;
			tmpFigure->sMoved = 0;
			 
			tmpFigure->sFigure = prmFigure;
			tmpFigure->sColor=prmColor;
	return tmpFigure;
}
void DrawFigure(HDC hdc, ptrFigure prmFigure)
{  
	  RECT  rcRect;
	  HPEN hPen = CreatePen( PS_SOLID, 2, RGB(0,0,0));
	  HBRUSH hBrush ;
	  TCHAR  redstr[4];
	  //GetDlgItemText(hEditr,ID_EDITR, redstr, 3);
	
	  hBrush = CreateSolidBrush(prmFigure->sColor);
	  
	  SelectObject(hdc, hPen);
	  SelectObject(hdc, hBrush);
	  switch(prmFigure->sFigure)
	  {
	  case ID_DRAW_SQUARE:
		  rcRect.left = prmFigure->sPoint1.x; rcRect.top = prmFigure->sPoint1.y;
		  rcRect.right = prmFigure->sPoint2.x; rcRect.bottom = prmFigure->sPoint2.y;
		  FillRect(hdc,&rcRect,hBrush );
		  Rectangle(hdc,prmFigure->sPoint1.x,prmFigure->sPoint1.y,prmFigure->sPoint2.x,prmFigure->sPoint2.y);

		  break;
	  case ID_DRAW_ELLIPSE:
		  
		  Ellipse(hdc,prmFigure->sPoint1.x,prmFigure->sPoint1.y,prmFigure->sPoint2.x,prmFigure->sPoint2.y);
		  
		  break;
	  default: //ID_DRAW_LINE
		  MoveToEx(hdc,prmFigure->sPoint1.x,prmFigure->sPoint1.y,NULL);
		  LineTo(hdc,prmFigure->sPoint2.x,prmFigure->sPoint2.y);
		  break;
	  }
	 
}

